<?php

namespace App\Http\Requests;

use App\Rules\LadderPriceRule;
use App\Rules\MapPointRule;
use Illuminate\Foundation\Http\FormRequest;

class DevicePost extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->getMethod()) {
            case 'POST':
            case 'PUT':
                return [
                    'name' => 'required|min:2|max:30',
                    'province_code' => 'required',
                    'city_code' => 'required',
                    'district_code' => 'required',
                    'address' => 'required|min:3',
                    'coordinate' => new MapPointRule(),
                    'ladder_price' => new LadderPriceRule()
                ];
        }
    }
}
